﻿using System;
using System.Linq;
using System.Text;
using DAL;
using Entity;
using Utils;
using Library;
using DataContext;
using System.Collections.Generic;

namespace PaymentBLL
{
    public class CtrLogPaymentGatewayIn
    {
        public int InsertLogPaymentGatewayIn(int accountId, string accountName, int accountTypeId,
            int paymentGatewayId, string paymentGatewayName, string paymentGatewayUnit,
            string paymentAccountInfo, string systemAccountInfo, int amountIn, int vndIn, int receiveAu, int receiveAg,
            int status, int? resultCode, string description, ref long? id)
        {
            return DB.PaymentInstance.uspLogPaymentGatewayInInsert(accountId, accountName, accountTypeId,
                paymentGatewayId, paymentGatewayName, paymentGatewayUnit,
                paymentAccountInfo, systemAccountInfo, amountIn, vndIn, receiveAu, receiveAg,
                status, resultCode, description, ref id);
        }

        public int UpdateLogPaymentGatewayIn(long id, int status, int? resultCode, string description)
        {
            if (description == string.Empty)
                description = null;
            return DB.PaymentInstance.uspLogPaymentGatewayInUpdate(id, status, resultCode, description);
        }

        public List<uspLogPaymentGatewayInSelectByResult> SelectLogPaymentGatewayInBy(long id, DateTime fromDate, DateTime toDate,
            int accountId, int accountTypeId, string accountName, int paymentGatewayId, string paymentGatewayName, string paymentGatewayUnit,
            ref int? totalVndIn, ref int? totalReceiveAu, ref int? totalReceiveAg,
            int currentPage, int pageSize, ref int? totalRecord)
        {
            return DB.PaymentInstance.uspLogPaymentGatewayInSelectBy(id, fromDate, toDate, accountId, accountTypeId, accountName,
                paymentGatewayId, paymentGatewayName, paymentGatewayUnit, ref totalVndIn, ref totalReceiveAu, ref totalReceiveAg,
                currentPage, pageSize, ref totalRecord).ToList();
        }

        public uspLogPaymentGatewayInStatisticsResult StatisticsLogPaymentGatewayIn(DateTime fromDate, DateTime toDate)
        {
            return DB.PaymentInstance.uspLogPaymentGatewayInStatistics(fromDate, toDate).FirstOrDefault();
        }

        public List<uspLogPaymentGatewayInSumStatisticsResult> StatisticsLogPaymentGatewayInSum(long id, DateTime fromDate, DateTime toDate,
            int accountId, int accountTypeId, string accountName)
        {
            return DB.PaymentInstance.uspLogPaymentGatewayInSumStatistics(id, fromDate, toDate, accountId, accountTypeId, accountName).ToList();
        }
    }
}
